if (SERVER) then
	AddCSLuaFile( "shared.lua" )
	SWEP.Weight		= 5
	SWEP.AutoSwitchTo	= false
	SWEP.AutoSwitchFrom	= false
end

if ( CLIENT ) then
	SWEP.DrawAmmo			= false
	SWEP.PrintName			= "Machinima Hands :D"
	SWEP.Author				= "cheesylard"
	SWEP.CheesylardDescription	= "\nPress Primary to cloak yourself.\nPress Secondary to cycle through holdtypes (and switch to them).\nHold E+Secondary to cycle between normal holdtype and the one you are currently using."
	SWEP.DrawCrosshair		= false
	SWEP.WepSelectIcon		= surface.GetTextureID( "vgui/entities/weaponless" )
end

SWEP.CheesylardDescription	= "\nPress Primary to cloak yourself.\nPress Secondary to cycle through holdtypes (and switch to them).\nHold E+Secondary to cycle between normal holdtype and the one you are currently using."

SWEP.Category = "*Machinima" 

SWEP.Spawnable     			= true
SWEP.AdminSpawnable  		= true
 
SWEP.ViewModel				= ""
SWEP.WorldModel				= ""
SWEP.Holdtypecycle			= 0

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Ammo = "none"
SWEP.Primary.Automatic		= false

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Ammo = false
SWEP.Secondary.Automatic = false

function SWEP:Initialize()
	if (CLIENT) then return end
	self:SetWeaponHoldType("normal")
end 

function SWEP:Holster()
	if self.Owner.Cloaked then
		self.Owner:PrintMessage( HUD_PRINTCENTER, "You're still invisible, see chat" )
		self.Owner:PrintMessage( HUD_PRINTTALK, "You're still invisible! In order to become visible again, change back to the 'machinima hands' SWep and left click again." )
	end
	return true
end

function SWEP:PrimaryAttack()
	if self.Owner.Cloaked then
		self.Owner:SetColor( 255, 255, 255, 255)
		self.Owner.Cloaked = false
		self.Owner:PrintMessage( HUD_PRINTCENTER, "Visible." )
	else
		self.Owner:SetColor( 255, 255, 255, 0)
		self.Owner.Cloaked = true
		self.Owner:PrintMessage( HUD_PRINTCENTER, "Invisible." )
	end
end

function SWEP:Deploy()
	if !self.noHelp then
		self.Owner:PrintMessage( HUD_PRINTTALK, "(Press reload to disable this notification)\n"..self.CheesylardDescription )
	end
return true
end

SWEP.Helptimer = 0
function SWEP:Reload()
	if self.Helptimer > CurTime() then return end
	self.Helptimer = CurTime() + 1
	if self.noHelp then
		self.noHelp = false
		self.Owner:PrintMessage( HUD_PRINTTALK, "Help notification enabled" )
	else
		self.noHelp = true
		self.Owner:PrintMessage( HUD_PRINTTALK, "Help notification disabled" )
	end
end
function SWEP:SecondaryAttack()
	if (SERVER) then
		if self.Owner:KeyDown(IN_USE) then
			if self.onotherone then
				self:SetWeaponHoldType("normal")
				self.Owner:PrintMessage( HUD_PRINTCENTER, "Hands by your side" )
				self.onotherone = false
			else
				if self.Holdtypecycle == 1 then
					self:SetWeaponHoldType("pistol")
					self.Owner:PrintMessage( HUD_PRINTCENTER, "Pistol/357" )
				elseif self.Holdtypecycle == 2 then
					self:SetWeaponHoldType("melee")
					self.Owner:PrintMessage( HUD_PRINTCENTER, "Crowbar/Melee" )
				elseif self.Holdtypecycle == 3 then
					self:SetWeaponHoldType("crossbow")
					self.Owner:PrintMessage( HUD_PRINTCENTER, "Shotgun/Crossbow" )
				elseif self.Holdtypecycle == 4 then
					self:SetWeaponHoldType("ar2")
					self.Owner:PrintMessage( HUD_PRINTCENTER, "Smg/AR2" )
				elseif self.Holdtypecycle == 0 then
					self:SetWeaponHoldType("normal")
					self.Owner:PrintMessage( HUD_PRINTCENTER, "Hands by your side" )
				end
				self.onotherone = true
			end
		return
		end
	
		if self.Holdtypecycle == 0 then
			self:SetWeaponHoldType("pistol")
			self.Owner:PrintMessage( HUD_PRINTCENTER, "Pistol/357" )
			self.Holdtypecycle = self.Holdtypecycle + 1
		elseif self.Holdtypecycle == 1 then
			self:SetWeaponHoldType("melee")
			self.Owner:PrintMessage( HUD_PRINTCENTER, "Crowbar/Melee" )
			self.Holdtypecycle = self.Holdtypecycle + 1
		elseif self.Holdtypecycle == 2 then
			self:SetWeaponHoldType("crossbow")
			self.Owner:PrintMessage( HUD_PRINTCENTER, "Shotgun/Crossbow" )
			self.Holdtypecycle = self.Holdtypecycle + 1
		elseif self.Holdtypecycle == 3 then
			self:SetWeaponHoldType("ar2")
			self.Owner:PrintMessage( HUD_PRINTCENTER, "Smg/AR2" )
			self.Holdtypecycle = self.Holdtypecycle + 1
		elseif self.Holdtypecycle == 4 then
			self:SetWeaponHoldType("normal")
			self.Owner:PrintMessage( HUD_PRINTCENTER, "Hands by your side" )
			self.Holdtypecycle = 0
		end
	end
end

--my custom draw thing (not really)
SWEP.hmm = "THIS WAS MADE MY CHEESY_LARD"
function SWEP:PrintWeaponInfo( x, y, alpha )
	if ( self.DrawWeaponInfoBox == false ) then return end
	if (self.InfoMarkup == nil ) then
		local str
		local lol = "<color=2,150,170,255>"
		str = "<font=HudSelectionText>"
		--I dont know why this works but it does
		if ( self.Author == "cheesylard" ) then str = str .. lol .. "(Made by "..self.Author..") "..self.CheesylardDescription .. "</color>\n" else str = str .. self.hmm .. "</color>\n" end
		str = str .. "</font>"
		self.InfoMarkup = markup.Parse( str, 250 )
	end
	surface.SetDrawColor( 255, 255, 255, alpha )
	surface.SetTexture( self.SpeechBubbleLid )
	surface.DrawTexturedRect( x, y - 64 - 5, 128, 64 ) 
	draw.RoundedBox( 8, x - 5, y - 6, 260, self.InfoMarkup:GetHeight() + 18, Color( 255, 255, 255, alpha ) )
	self.InfoMarkup:Draw( x+5, y+5, nil, nil, alpha )
end